import React from 'react';
import {WeaDialog} from 'ecCom'
import {WeaErrorPage,WeaTools,WeaLocaleProvider} from 'ecCom'
import {Button} from 'antd'
const getLabel = WeaLocaleProvider.getLabel;

class TipsModalInfo extends React.Component {
    constructor(props){
        super(props);
        this.state={
            tipsModalVisible:this.props.visible||false,
            showInfo:this.props.showInfo || ''
        }
    }
    componentWillReceiveProps(nextProps) {
        if(nextProps.visible!== this.state.tipsModalVisible||nextProps.showInfo!=this.state.showInfo) {
            this.setState({
                tipsModalVisible:nextProps.visible,
                showInfo:nextProps.showInfo
            })
        }
    }

    tipsModalCancel = ()=>{
      const{cancelHandle} = this.props;
        this.setState({
            tipsModalVisible:false,
            showInfo:''
        });
        cancelHandle&&cancelHandle();
    }
    
    render(){
        const { tipsModalVisible , showInfo} =this.state;
        const{cancelHandle} = this.props;
        return(
            <div>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@egmp16`} 
                    className="tips-modal-info-commons"
                    title={getLabel(131329,' 信息确认')}
                    icon={'icon-coms-Prompt ant-confirm-header-icon'}
                    iconBgcolor={'none'}
                    visible={tipsModalVisible}
                    buttons={<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@3ix4np`} type="primary" onClick={()=>{
                        this.setState({
                            tipsModalVisible:false,
                            showInfo:''
                        });
                        cancelHandle&&cancelHandle();
                    }}>{getLabel(83446,'确定')}</Button>}
                    children={showInfo}
                    closable={true}
                    style={{width:'400px',height:'none'}}
                    onCancel={this.tipsModalCancel}
                />
            </div>
        )
    }
}
export default WeaTools.tryCatch(React,
    props => <WeaErrorPage ecId={`${this && this.props && this.props.ecId || ''}_WeaErrorPage@act6v5`} msg={ props.error ? props.error : getLabel(383324,' 对不起，该页面异常，请联系管理员 ')+'！'} />,
    {error: ""}
    )(TipsModalInfo);


